import React from 'react';
import { inject, observer } from 'mobx-react';
import { Spin, Modal, Button, message } from 'antd';
import { WeaInput, WeaDatePicker, WeaUpload, WeaTextarea, WeaInputNumber, WeaNewScroll, WeaDialog, WeaRichText, WeaFormItem, WeaTable, WeaBrowser, WeaLocaleProvider, WeaPopoverHrm, WeaSearchGroup } from 'ecCom';
import NewLinkeb from '../../../public/newlinked/NewLinkeb';
import TaskDetailDialog from '../../task/TaskDetailDialog';
import '../../../style/plan/planDetailView.less';
import FeedBack from '../../../public/feedback/FeedBack';
import * as Util from '../../../util/Util.js';
const toJS = mobx.toJS;
const confirm = Modal.confirm
const getLabel = WeaLocaleProvider.getLabel;
@inject('planDetailViewStore')
@observer
export default class PlanDetail extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            showKey: '',
            locationkey: '',
            showvisible: '',
            canedit: false,
            datatype: '2',
            detailid: '',
            category: '',
            summaryInCantEditFields: [],
            inOrOut: ''
        };
        this.store = this.props.planDetailViewStore;
        this.mirror = {
            37: '/spa/document/index.jsp?id=',
            7: '/spa/crm/mobx/index.html#/main/crm/customerView?customerId=',
            152: '/workflow/request/ViewRequestForwardSPA.jsp?requestid=',
            8: '/spa/prj/index.html#/main/prj/projectCard?prjid=',
            1: '/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/',
            wrltsk: '/spa/workrelate/static/index.html#/main/workrelate/task/taskDetail?id=',
        };
    }
    componentWillMount() {

    }
    componentDidMount() {
        //一些初始化请求
        this.setState({ ...this.state, ...this.props }, () => {
            const { canedit, datatype, detailid, category } = this.state;
            this.store.getDetailView({
                plandetailid: detailid,
                datatype: datatype,
                category: category,
                // programid: this.props.planReportViewStore.resData.programid
            });
            this.setState({ key: detailid })
        })

    }
    componentWillReceiveProps(nextProps) {
        this.setState({ ...this.state, ...nextProps })
    }


    render() {
        const {
            visible,
            inOrOut,
            rowIndex,
            type,
            planstatus,
            canedit, locationkey, showvisible, showKey, summaryInCantEditFields
        } = this.state;
        let {
            spinning,
            editParams,
            emptyArray,
            showtask,
            feedbackContent,
            fblist,
            fblastcount,
            emptyReplaceDatas,
            customList,
            category,
            refreshMark
        } = this.store;
        console.log(customList)
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@bcczil`}
                visible={visible}
                title={getLabel('509039', '计划详情')}
                icon="icon-coms-implement"
                iconBgcolor='rgb(150, 53, 138)'
                className="createWorkPlan"
                buttons={this.getButton()}
                style={
                    this.props.style || { width: window.innerWidth * 0.5, height: window.innerHeight - 140 }
                }
                closable={true}
                onCancel={this.onClose}
            >
                <div className="wea-workrelate-plan-detailview">
                    <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@q9hfb3`} spinning={spinning}>
                        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@1qk140`}
                            height={
                                this.props.style
                                    ? this.props.style.height
                                    : window.innerHeight - 190
                            }
                        >
                            <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@wg48xb`} />
                            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@7otwpz`} title={getLabel('81711', '基本信息')} needTigger={true} showGroup={true}>
                                {customList &&
                                    customList.length > 0 &&
                                    customList.map((element, idx) => {
                                        let elementCanEdit = toJS(canedit)//拷贝防止修改canedit导致后续的都错
                                        //如果能编辑，看是计划内还是外。计划内的，有些字段不能编辑
                                        if (elementCanEdit) {
                                            if (inOrOut == 'in' && summaryInCantEditFields.indexOf(element.fieldname) > -1) {
                                                elementCanEdit = false
                                            }
                                        }
                                        let editAuth = elementCanEdit ? (element.ismust == '1' ? 3 : 2) : 1
                                        return (
                                            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@l4fx7n@${element.fieldname}`}
                                                label={element.showname}
                                                labelCol={{ span: 4 }}
                                                wrapperCol={{ span: 18 }}
                                                className={
                                                    element.inputtype == 3
                                                        ? 'plan-item-' + element.fieldname
                                                        : ''
                                                }
                                            >
                                                {element.inputtype == 1 &&
                                                    <div>
                                                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@f6sq2r@${element.fieldname}`}
                                                            onBlur={value => {
                                                                this.onInputChange(value, element.fieldname, element.ismust)
                                                            }
                                                            }
                                                            value={editParams[element.fieldname]}
                                                            placeholder={getLabel('83869', '请输入') + element.showname}
                                                            viewAttr={editAuth}
                                                        />
                                                    </div>
                                                }
                                                {element.inputtype == 2 &&
                                                    <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@loi14y@${element.fieldname}`}
                                                        //defaultValue={element.showval}
                                                        onBlur={value => {
                                                            this.onInputChange(value, element.fieldname, element.ismust)
                                                        }}
                                                        value={editParams[element.fieldname]}
                                                        viewAttr={editAuth}
                                                    />}
                                                {element.inputtype == 3 &&

                                                    <WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@0t8jjy@${element.fieldname}`}
                                                        //defaultValue={element.showval}
                                                        onChange={value => {
                                                            this.onDateChange(value, element.fieldname, element.ismust)
                                                        }
                                                        }
                                                        value={editParams[element.fieldname]}
                                                        viewAttr={editAuth}
                                                    />}
                                                {element.inputtype == 4 &&
                                                    <WeaInputNumber ecId={`${this && this.props && this.props.ecId || ''}_WeaInputNumber@h9n12r@${element.fieldname}`}
                                                        //defaultValue={element.showval}
                                                        value={editParams[element.fieldname]}
                                                        viewAttr={editAuth}
                                                        onChange={value => {
                                                            this.onInputChange(value, element.fieldname, element.ismust)
                                                        }}
                                                    />
                                                }
                                            </WeaFormItem>
                                        );
                                    })}
                            </WeaSearchGroup>

                            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@z7rc14`} title={getLabel('22078', '相关信息')} needTigger={true} showGroup={true}>
                                {showtask &&
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ihzo3v`}
                                        label={getLabel('33414', '相关任务')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}
                                        className="plan-item-task"
                                    >
                                        <div className="xgrw-div">

                                            <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@g6u36f`}
                                                onChange={(ids, names, datas) => {
                                                    this.onChangeBrowser(
                                                        ids,
                                                        names,
                                                        datas,
                                                        'taskids',
                                                        'taskarray'
                                                    );
                                                }}
                                                replaceDatas={editParams['taskarray']}
                                                linkUrl={this.mirror['wrltsk']}
                                                title={getLabel('33414', '相关任务')}
                                                type="wrltsk"
                                                viewAttr={canedit ? 2 : 1}
                                                isSingle={false}
                                                inputStyle={{ width: '100%' }}
                                            />

                                        </div>
                                    </WeaFormItem>}
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@6cp658`}
                                    label={getLabel('857', '相关文档')}
                                    labelCol={{ span: 4 }}
                                    wrapperCol={{ span: 18 }}
                                    className="plan-item-doc"
                                >

                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@y6wg73`}
                                        title={getLabel('857', '相关文档')}
                                        type={9}
                                        inputStyle={{ width: '100%' }}
                                        viewAttr={canedit ? 2 : 1}
                                        replaceDatas={editParams['docarray']}
                                        linkUrl={this.mirror[37]}
                                        onChange={(ids, names, datas) =>
                                            this.onChangeBrowser(
                                                ids,
                                                names,
                                                datas,
                                                'docids',
                                                'docarray'
                                            )}
                                        isSingle={false}
                                    />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ys7lk1`}
                                    label={getLabel('22105', '相关流程')}
                                    labelCol={{ span: 4 }}
                                    wrapperCol={{ span: 18 }}
                                    className="plan-item-wf"
                                >

                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@v9blxj`}
                                        title={getLabel('22105', '相关流程')}
                                        type={16}
                                        inputStyle={{ width: '100%' }}
                                        onChange={(ids, names, datas) =>
                                            this.onChangeBrowser(
                                                ids,
                                                names,
                                                datas,
                                                'wfids',
                                                'wfarray'
                                            )}
                                        replaceDatas={editParams['wfarray']}
                                        linkUrl={this.mirror[152]}
                                        viewAttr={canedit ? 2 : 1}
                                        isSingle={false}
                                    />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@2qabq6`}
                                    label={getLabel('783', '相关客户')}
                                    labelCol={{ span: 4 }}
                                    wrapperCol={{ span: 18 }}
                                    className="plan-item-crm"
                                >

                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@9dwwk0`}
                                        title={getLabel('783', '相关客户')}
                                        type={7}
                                        inputStyle={{ width: '100%' }}
                                        replaceDatas={editParams['crmarray']}
                                        linkUrl={this.mirror[7]}
                                        viewAttr={canedit ? 2 : 1}
                                        onChange={(ids, names, datas) =>
                                            this.onChangeBrowser(
                                                ids,
                                                names,
                                                datas,
                                                'crmids',
                                                'crmarray'
                                            )}
                                        isSingle={false}
                                    />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@wp2139`}
                                    label={getLabel('782', '相关项目')}
                                    labelCol={{ span: 4 }}
                                    wrapperCol={{ span: 18 }}
                                    className="plan-item-project"
                                >

                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@4v2lsz`}
                                        title={getLabel('782', '相关项目')}
                                        type={8}
                                        inputStyle={{ width: '100%' }}
                                        linkUrl={this.mirror[8]}
                                        replaceDatas={editParams['projectarray']}
                                        viewAttr={canedit ? 2 : 1}
                                        onChange={(ids, names, datas) =>
                                            this.onChangeBrowser(
                                                ids,
                                                names,
                                                datas,
                                                'projectids',
                                                'projectarray'
                                            )}
                                        isSingle={false}
                                    />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@h3x4cw`}
                                    label={getLabel('22194', '相关附件')}
                                    labelCol={{ span: 4 }}
                                    wrapperCol={{ span: 18 }}
                                    className="plan-item-file"
                                >
                                    <div className="xgfj-div">
                                        <div className="linked-div">
                                            {refreshMark && <NewLinkeb ecId={`${this && this.props && this.props.ecId || ''}_NewLinkeb@yu2lla`}
                                                onLinkClick={(id, name, type, fileid) =>
                                                    this.onLinkClick(
                                                        id,
                                                        name,
                                                        type,
                                                        'fileids',
                                                        'filearray',
                                                        fileid
                                                    )}
                                                linkurl=""
                                                hasdownload={true}
                                                linkdatas={editParams.filearray}
                                                hasdel={canedit}
                                            />}
                                        </div>
                                        {canedit &&
                                             this.store.uploadReset &&
                                            <div className="xgfj-edit">
                                                <WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@c0q2y0`}
                                                    uploadUrl={
                                                        '/api/doc/upload/uploadFile2Doc?category=' + (category)
                                                    }
                                                    category={category}
                                                    showClearAll={false}
                                                    onChange={(ids, list) =>
                                                        this.uploadChange(ids, list)}
                                                />
                                            </div>}
                                    </div>
                                </WeaFormItem>
                            </WeaSearchGroup>
                            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@48dbda`} title={getLabel('83596', '反馈信息')} needTigger={true} showGroup={true}>
                                <WeaRichText ecId={`${this && this.props && this.props.ecId || ''}_WeaRichText@yv287u`}
                                    onChange={v => this.setfeedbackContent(v)}
                                    value={feedbackContent}
                                    ckConfig={{
                                        toolbar: [
                                            { name: 'document', items: ['Source'] },
                                            {
                                                name: 'paragraph',
                                                items: [
                                                    'JustifyLeft',
                                                    'JustifyCenter',
                                                    'JustifyRight',
                                                    '-',
                                                    'NumberedList',
                                                    'BulletedList',
                                                ],
                                            },
                                            { name: 'styles', items: ['Format', 'Font', 'FontSize'] },
                                            { name: 'colors', items: ['TextColor'] },
                                            {
                                                name: 'basicstyles',
                                                items: ['Bold', 'Italic', 'Underline', 'Strike'],
                                            },
                                            { name: 'insert', items: ['Table', 'Smiley'] },
                                        ],
                                        height: 80,
                                        startupFocus: false,
                                        autoGrow_minHeight: 80,
                                        autoGrow_maxHeight: 80,
                                    }}
                                    bottomBarRight={{
                                        width: 100,
                                        Component: [
                                            <span
                                                className="wea-rich-text-toolbar-bottom-item"
                                                style={{ position: 'relative' }}
                                            >
                                                <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@t7e3nr@submit`} className="wea-button-release" onClick={() => this.planRelease()}>
                                                    <span>
                                                        <span className="icon-coms-Release" />
                                                        <span style={{ marginLeft: '2px' }}>{getLabel('615', '提交')}</span>
                                                    </span>
                                                </Button>
                                            </span>,
                                        ],
                                    }}
                                    onToolsChange={(name, ids, list, type) =>
                                        Util.transfStr(name, ids, list, type, this.mirror)}
                                />

                                {fblist.map(v => {
                                    v.operatedate = v.datetime;
                                })}
                                {fblist &&
                                    fblist.length > 0 &&
                                    <FeedBack ecId={`${this && this.props && this.props.ecId || ''}_FeedBack@fqs40b`} dataSource={fblist} />}

                                {fblastcount > 0 &&
                                    <div
                                        className="tabs-Feedback-more"
                                        onClick={() => this.onMoreFeedbackClick()}
                                    >
                                        {getLabel('387979', '加载更多')} <Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@h0xwdm`} type="down" />
                                    </div>}

                            </WeaSearchGroup>
                            <TaskDetailDialog ecId={`${this && this.props && this.props.ecId || ''}_TaskDetailDialog@kgqg03`}
                                detailKey={showKey}
                                locationkey={locationkey}
                                visable={showvisible}
                                onlyClose={() => this.setState({ showvisible: false })}
                                style={{
                                    width: 900,
                                    height: this.props.style
                                        ? this.props.style.height
                                        : window.innerHeight - 140,
                                }}
                            />
                        </WeaNewScroll>
                    </Spin>
                </div>
            </WeaDialog>
        );
    }

    getButton = () => {
        let buttonsCreate = [];
        buttonsCreate.push(
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@631hy9@close`} type="ghost" onClick={this.onClose}>{getLabel('309', '关闭')}</Button>
        );

        return buttonsCreate;
    };
    onClose = () => {
        if (typeof this.props.onClose === 'function') {
            this.props.onClose(this.store.editParams, this.props.detailid);
        }
    }
    setfeedbackContent(v) {
        this.store.setValue('feedbackContent', v)
    }
    onMoreFeedbackClick() {
        this.store.getFbInfo({ plandetailid: this.props.detailid });
    }
    onInputChange = (val, type, ismust) => {
        let { resourceid } = this.props;
        if (ismust == 1 && (val == undefined || val == "")) {
            message.info(getLabel('509065', '请输入必填项'));
            return;
        }
        let {editParams}= this.store
        editParams[type] = val;
        editParams["s_" + type] = typeof (val) == 'string' ? val.replace(/\n/g, "<br/>") : val;
        this.store.setValue("editParams",editParams)
        this.store.saveDetailView({
            fieldname: type,
            fieldvalue: val,
            plandetailid: this.props.detailid,
            resourceid: resourceid,
            fieldtype: 'str',
        });

    }
    onChangeBrowser(ids, names, datas, typeIds, typeArray) {
        let {
            resourceid,
            canedit,
            datatype,
            detailid,
        } = this.props;
        if (ids && typeof ids == "string" && !ids.endsWith(",")) ids += ','
        let {editParams} = this.store
        editParams[typeIds] = ids;
        this.store.setValue("editParams",editParams)
        this.store.saveDetailView({
            fieldname: typeIds,
            fieldvalue: ids,
            plandetailid: this.props.detailid,
            resourceid: resourceid,
            fieldtype: 'str',
            doback:()=>{this.store.getDetailView({
                plandetailid:  detailid,
                datatype: datatype,
                category: this.state.category,
            })}
        });
    }
    onDateChange(val, type, ismust) {
        let { planDetailViewStore, resourceid } = this.props;
        if (ismust == 1 && (val == undefined || val == "")) {
            //planDetailViewStore.editParams[type] = "";
            message.info(getLabel('509065', '请输入必填项'));
            return;
        }
        //深拷贝
        let beforeValue = JSON.parse(
            JSON.stringify(toJS(planDetailViewStore).editParams)
        )[type];
        let flag = true;
        let days = 0;
        let tip = '';
        let col = '';
        if (val != '') {
            if (
                type == 'begindate2' &&
                planDetailViewStore.editParams['enddate2'] != ''
            ) {
                days = Util.DateDiffDays(
                    val,
                    planDetailViewStore.editParams['enddate2']
                );
                if (days < 0) {
                    flag = false;
                    tip = getLabel('509026', '实际开始日期不能大于实际结束日期!');
                } else {
                    col = 'days2';
                }
            } else if (
                type == 'enddate2' &&
                planDetailViewStore.editParams['begindate2'] != ''
            ) {
                days = Util.DateDiffDays(
                    planDetailViewStore.editParams['begindate2'],
                    val
                );
                if (days < 0) {
                    flag = false;
                    tip = getLabel('509027', '实际结束日期不能小于实际开始日期!');
                } else {
                    col = 'days2';
                }
            } else if (
                type == 'begindate1' &&
                planDetailViewStore.editParams['enddate1'] != ''
            ) {
                days = Util.DateDiffDays(
                    val,
                    planDetailViewStore.editParams['enddate1']
                );
                if (days < 0) {
                    flag = false;
                    tip = getLabel('509028', '计划开始日期不能大于计划结束日期!');
                } else {
                    col = 'days1';
                }
            } else if (
                type == 'enddate1' &&
                planDetailViewStore.editParams['begindate1'] != ''
            ) {
                days = Util.DateDiffDays(
                    planDetailViewStore.editParams['begindate1'],
                    val
                );
                if (days < 0) {
                    flag = false;
                    tip = getLabel('509029', '计划结束日期不能小于计划开始日期!');
                } else {
                    col = 'days1';
                }
            }
        }
        if (flag) {
            planDetailViewStore.canView = false;
            planDetailViewStore.editParams[type] = val;
            planDetailViewStore.editParams["s_" + type] = val;
            if (col != '') {
                planDetailViewStore.editParams[col] = days;
                planDetailViewStore.editParams["s_" + col] = days;
            }
            planDetailViewStore.saveDetailView({
                fieldname: type,
                fieldvalue: val,
                plandetailid: this.props.detailid,
                resourceid: resourceid,
                fieldtype: 'str',
                otherfield: col,
                othervalue: days,
            });
            planDetailViewStore.canView = true;
        } else {
            planDetailViewStore.canView = false;
            planDetailViewStore.editParams[type] = '';
            planDetailViewStore.editParams["s_" + type] = "";
            planDetailViewStore.editParams[type] = beforeValue;
            planDetailViewStore.editParams["s_" + type] = beforeValue;
            message.info(tip);
            planDetailViewStore.canView = true;
        }
        return flag
    }

    //反馈 发布
    planRelease() {
        if (this.store.feedbackContent != '') {
            this.store.saveDetailView({
                plandetailid: this.state.key,
                content: this.store.feedbackContent,
                operation: 'add_feedback',
            });
        } else {
            Modal.warning({
                title: getLabel('558', '提示'),
                content: getLabel('508792', '反馈信息不能为空!'),
            });
        }
    }
    /**上传附件 */
    uploadChange(ids, list) {
        let { resourceid } = this.props;
        let {detailid} = this.state
        if (ids.length > 0) {
            let newAddFileids = '';
            if (this.store.editParams['fileids'] == undefined) {
                this.store.editParams['fileids'] = '';
                this.store.editParams['filearray'] = [];
            }

            for (let i = 0; i < list.length; i++) {
                let fileA = {};
                if (
                    this.store.editParams.fileids.indexOf(',' + ids[i] + ',') ==
                    -1
                ) {
                    this.store.editParams.fileids += ids[i] + ',';
                    fileA.id = ids[i];
                    fileA.name = list[i].filename;
                    fileA.size = list[i].filesize;
                    fileA.fileid = list[i].imagefileid;
                    this.store.editParams.filearray.push(fileA);
                }
            }
            this.store.setValue('uploadReset',false)
            let _ = this
            this.store.saveDetailView({
                fieldname: 'fileids',
                fieldvalue: ids,
                plandetailid: detailid,
                resourceid: resourceid,
                doback: function () {
                    _.store.setValue('uploadReset',true)
                },
            });
        }
    }
    onLinkClick(id, name, type, typeIds, typeArray, fileid) {
        let {  resourceid,detailid } = this.state;
        if (type == 2) {
            //删除
            let sendValue = '';
            let fieldtype = 'str';
            let vals = this.store.editParams[typeIds];
            if (vals.length > 0 && !Util.startWith(vals, ',')) {
                vals = ',' + vals;
            }
            if (vals.length > 0 && !Util.endWith(vals, ',')) {
                vals = vals + ',';
            }
            let _index = vals.indexOf(',' + id + ',');
            if (_index > -1 && id != '') {
                vals =
                    vals.substring(0, _index + 1) +
                    vals.substring(_index + (id + '').length + 2);
                if (vals == ',') {
                    vals = '';
                }
                this.store.editParams[typeIds] = vals;
                if (typeIds == 'fileids') {
                    //附件
                    sendValue = id;
                    fieldtype = 'del';
                } else {
                    //其他
                    sendValue = vals;
                }
            }
            //对array进行处理
            let array = this.store.editParams[typeArray];
            let tempIndex =-1
            array.map((elemnet, index) => {
                if (elemnet.id == id) {
                    tempIndex= this.store.editParams[typeArray].indexOf(
                        elemnet
                    );
                }
            });
            if(tempIndex >-1){
                this.store.removeFromFileArray(tempIndex)
            }
            let _ = this
            _.store.setValue("refreshMark",false)
            this.store.saveDetailView({
                fieldname: typeIds,
                fieldvalue: sendValue,
                plandetailid: this.state.key,
                resourceid: resourceid,
                fieldtype: fieldtype,
                doback:()=>{
                    _.store.setValue("refreshMark",true)
                }
            });
        } else if (type == 1) {
           this.store.viewDocFiled({
                id: id,
                plandetailid: detailid,
                relateId: detailid,
                type: 4,
                doback: function () {
                    Util.opendoc(id);
                },
            });
        } else {
            this.store.viewDocFiled({
                id: id,
                plandetailid: detailid,
                relateId: detailid,
                type: 4,
                doback: function () {
                    Util.downloads(fileid);
                },
            });
        }
    }

}
